/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package repository;

import static modelHibernate.HibernateUtil.getSessionFactory;
import java.util.List;
import modelBanco.ParUsuarios;
import org.hibernate.Query;
import org.hibernate.Session;


/**
 *
 * @author cesar
 */
public class ParUsuariosRepository {
    
    public List<ParUsuarios> buscarUsuario(String login, String senha){
        
        Session session = getSessionFactory().openSession();
        
        if(session == null)
            session = getSessionFactory().getCurrentSession();
        
        Query hql = session.createQuery("from ParUsuarios as parUsuarios where parUsuarios.loginUsuario = :login and parUsuarios.senhaUsuario = :senha ");
        
        hql.setString("login", login);
        hql.setString("senha", senha);
        
        List<ParUsuarios> retorno = hql.list();
        
        return retorno;
       
    }
    
}
